CC = gcc
FLAGS = -Wall -Werror
LINK = -lrt
TESTS = ./files_tests/

all: emulator routetrace

# Original Tests
	- cp -r ./files_source/emulator1 ./emulator1
	- cp -r ./files_source/emulator2 ./emulator2
	- cp -r ./files_source/emulator3 ./emulator3
	- cp -r ./files_source/emulator4 ./emulator4
	- cp -r ./files_source/emulator5 ./emulator5
	- cp emulator emulator1
	- cp emulator emulator2
	- cp emulator emulator3
	- cp emulator emulator4
	- mv emulator emulator5

#- cp -r ./files_source/requester1 ./requester1
#- mv requester requester1
#- rm requester1/hello.txt
#- rm requester1/split.txt

test: test_queue test_rand test_time
	- rm $(TESTS)test_results.txt
	- $(TESTS)test_queue >> $(TESTS)test_results.txt
	- rm $(TESTS)test_queue
	- $(TESTS)test_rand >> $(TESTS)test_results.txt
	- rm $(TESTS)test_rand
	- $(TESTS)test_time >> $(TESTS)test_results.txt
	- rm $(TESTS)test_time
	- cat $(TESTS)test_results.txt

emulator: emulator.c network.h util.h queue.h forward_table.h topology.h
	$(CC) $(LINK) $(FLAGS) emulator.c -o emulator

sender: sender.c network.h util.h
	$(CC) $(LINK) $(FLAGS) sender.c -o sender

requester: requester.c network.h util.h
	$(CC) $(LINK) $(FLAGS) requester.c -o requester

routetrace: routetrace.c network.h util.h
	$(CC) $(LINK) $(FLAGS) routetrace.c -o routetrace

# UNIT TESTS
test_queue: $(TESTS)test_queue.c queue.h
	$(CC) $(LINK) $(FLAGS) $(TESTS)test_queue.c -o $(TESTS)test_queue

test_rand: $(TESTS)test_rand.c util.h
	$(CC) $(LINK) $(FLAGS) $(TESTS)test_rand.c -o $(TESTS)test_rand

test_time: $(TESTS)test_time.c util.h
	$(CC) $(LINK) $(FLAGS) $(TESTS)test_time.c -o $(TESTS)test_time

clean:
#	- rm -r sender1/
#	- rm -r sender2/
#	- rm -r requester1/
	- rm -r emulator1
	- rm -r emulator2
	- rm -r emulator3
	- rm -r emulator4
	- rm -r emulator5
#	- rm mylog.txt
